//
// Created by user on 2025/7/30.
//

#ifndef HELLOC_EVENT_H
#define HELLOC_EVENT_H

#include "systemc"
#include <iostream>
using namespace std;
using namespace sc_core;

class Event : public sc_module {
public:
    sc_event e1;

    void trigger(){
        while (true){
            e1.notify(1,SC_SEC);
            if(sc_time_stamp() == sc_time(4,SC_SEC))
                e1.cancel();
            wait(2,SC_SEC);
        }
    }

    void catcher(){
        while (true){
            wait(e1);
            cout << "Event catched at " << sc_time_stamp() << endl;
        }
    }

    Event(sc_module_name name){
        SC_THREAD(trigger);
        SC_THREAD(catcher);
    }


};


#endif //HELLOC_EVENT_H
